<!--文章分类页 ArticleView.vue-->
<template>
  <div style="height: 6vh;background-color:#fff;padding:10px 20px;">
    <span style="line-height:60px;font-size:20px;">信息管理</span>
    <el-button type="primary" style="float:right;margin-top:13px;" @click="beforeAddBusiness">推文创作</el-button>
  </div>
  <!-- 查询条件卡片 -->
  <el-card style="margin:20px;height: 70px;">
    <el-form :inline="true">
      <el-form-item label="文章标题">
        <el-input placeholder="请输入" style="width:300px;" v-model="searchForm.name" ></el-input>
      </el-form-item>
      <el-form-item label="文章分类" style="width:300px;">
        <el-select placeholder="请选择" v-model="searchForm.article" @change="load">
          <el-option label="全部" value="0"/>
          <el-option label="启用" value="1"/>
          <el-option label="禁用" value="2"/>
        </el-select>
      </el-form-item>
      <el-form-item label="更新日期" style="width:290px;">
        <el-date-picker
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="YYYY-MM-DD HH:mm:ss"
            format="YYYY-MM-DD HH:mm:ss"
            v-model="times"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="resetSearch">重置</el-button>
        <el-button type="primary" @click="load">查询</el-button>
      </el-form-item>
    </el-form>
  </el-card>
  <!-- 列表表格数据 -->
  <el-card style="margin:20px;">
    <h3>推文列表</h3>
    <el-table stripe :data="tableData">
      <el-table-column label="编号" prop="id" type="index" align="center" width="100"></el-table-column>
      <el-table-column label="文章标题" prop="name" align="center"></el-table-column>
      <el-table-column label="文章分类" prop="sort" align="center"></el-table-column>
      <el-table-column label="标签" prop="tags" align="center"></el-table-column>
      <el-table-column label="最后修改时间" prop="updateTime" align="center"></el-table-column>
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-button type="primary" link @click="">上线</el-button>
          <el-button type="primary" link @click="editArticle">编辑</el-button>
          <el-button type="primary" link @click="deleteArticle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
  <!-- 新建弹窗 -->
  <el-dialog title="新建分类" v-model="dialogVisible"
             style="width: 1000px;padding: 40px;" :before-close="handleClose">
    <el-form>
      <el-form-item label="文章标题">
        <el-input placeholder="请输入文章标题" v-model="newForm.name" style="width:300px;"></el-input>
      </el-form-item>
      <el-form-item label="文章标签">
        <el-select placeholder="请选择文章标签" v-model="newForm.category" style="width:300px;">
          <el-option label="娱乐" value="0"></el-option>
          <el-option label="没事" value="1"></el-option>
          <el-option label="阅读" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="文章标签">
        <el-select placeholder="请选择文章标签" v-model="newForm.tags" style="width:300px;">
          <el-option label="电影" value="0"></el-option>
          <el-option label="娱乐" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="文章摘要">
        <el-input placeholder="请输入文章摘要" type="textarea"  v-model="newForm.name" style="width:300px;"></el-input>
      </el-form-item>
      <el-form-item label="文章封面">
        <el-upload></el-upload>
      </el-form-item>
      <el-form-item label="主图图片">
        <el-upload></el-upload>
      </el-form-item>
      <el-form-item label="文章详情">
        <el-input placeholder="请输入文章详情" type="textarea" v-model="newForm.name" style="width:300px;" ></el-input>
      </el-form-item>
      <el-form-item label="门店状态">
        <el-radio-group  v-model="newForm.status">
          <el-radio  label="开启" value="1" ></el-radio>
          <el-radio  label="禁用" value="0"></el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="handleClose">取消</el-button>
      <el-button  type="primary" @click="save">保存</el-button>
    </template>
  </el-dialog>
</template>
<script setup>
import {onMounted, ref} from "vue";
import qs from "qs";
const times =ref([]);
const dialogVisible = ref(false);
const beforeAddBusiness=()=>{
  dialogVisible.value = true;
}
const searchForm = ref({name: '', status: ''})
const tableData = ref([]);
const load = ()=>{
  let data = qs.stringify(searchForm.value);
  // axios.get(BASE_URL+'/v1/geofence/select?'+data).then((response)=>{
  //   if(response.data.code == 2000){
  //     geoTableData.value = response.data.data;
  //   }else{
  //     ElMessage.error(response.data.msg);
  //   }
  // })
}
onMounted(()=>{
  load();
})
const resetSearch = ()=>{
  searchForm.value = {name: '', status: ''};
  load();
}
// 编辑
const editArticle= ()=>{}
const newForm = ref({
  name: '',
  sort: '',
  status: '',
});
const save = ()=>{}
const deleteArticle = (id)=>{
  if(confirm('您确认要删除本店铺吗?')){
  }
}
// 定义处理弹窗关闭的方法
const handleClose=()=>{
  if (confirm('确定要取消保存吗？')) {
    newForm.value = {};
    dialogVisible.value = false;
  }
}
</script>



<style scoped>
</style>